interface ConsultTableModel {
  list: Array<any>
}

interface MenuModel {
  menuId: number
  menuParentId: number
  menuName: string
  menuCode: string
  menuSort: number
  statusFlag: number
  remark: string
  antdvRouter: string
  antdvComponent: string
  antdvIcon: string
  antdvLinkUrl: string
  antdvActiveUrl: string
  antdvVisible: string
  versionFlag: number
  delFlag: string
  children?: MenuModel[]
}

type ConsultTableParams = Partial<Omit<MenuModel, 'id'>>

export async function tree(params?: MenuModel) {
  return usePost<MenuModel[]>('/menu/tree', params)
}

export async function deleteApi(id: string | number) {
  return useDelete(`/menu/${id}`)
}

export async function saveApi(params: MenuModel) {
  return usePost<MenuModel>('/menu/add', params)
}

export async function updateApi(params: MenuModel) {
  return usePost<MenuModel>('/menu/update', params)
}

export async function detailApi(id: string | number) {
  return useGet<MenuModel>(`/menu/detail/${id}`)
}

export type{
  ConsultTableParams,
  MenuModel,
  ConsultTableModel,
}
